<?php

namespace app\admin\controller;

use app\admin\service\CarService;
use app\admin\service\CarTypeService;

class CarController extends CommonController
{
    // 获取车辆类型数据的分页列表
    public function getCarTypeList(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(CarTypeService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->getList();
        return $this->return_result($this->returnData);
    }

    // 添加车辆类型
    public function toAddCarType(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(CarTypeService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->toAdd();
        return $this->return_result($this->returnData);
    }

    // 更新车辆类型
    public function toUpdateCarType(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(CarTypeService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->toUpdate();
        return $this->return_result($this->returnData);
    }

    // 车辆类型的详细内容
    public function getCarTypeDetail(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(CarTypeService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->getDetail();
        return $this->return_result($this->returnData);
    }

    // 更新车辆类型的权重
    public function toUpdateOrderByCarType(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(CarTypeService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->toUpdateOrderBy();
        return $this->return_result($this->returnData);
    }

    // 更新车辆类型的状态
    public function toUpdateStatusCarType(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(CarTypeService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->toUpdateStatus();
        return $this->return_result($this->returnData);
    }

    // 删除车辆类型
    public function toDelCarType(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(CarTypeService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->toDel();
        return $this->return_result($this->returnData);
    }

    // 获取所有可用的车辆类型
    public function getChooseCarType(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(CarTypeService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->getChoose();
        return $this->return_result($this->returnData);
    }

    // 获取所有可用的车辆
    public function getChooseCar(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(CarService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->getChoose();
        return $this->return_result($this->returnData);
    }

    // 获取车辆的分页列表
    public function getCarList(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(CarService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->getList();
        return $this->return_result($this->returnData);
    }

    // 添加车辆
    public function toAddCar(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(CarService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->toAdd();
        return $this->return_result($this->returnData);
    }

    // 更新车辆
    public function toUpdateCar(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(CarService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->toUpdate();
        return $this->return_result($this->returnData);
    }

    // 车辆的详细内容
    public function getCarDetail(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(CarService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->getDetail();
        return $this->return_result($this->returnData);
    }

    // 更新车辆的状态
    public function toUpdateStatusCar(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(CarService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->toUpdateStatus();
        return $this->return_result($this->returnData);
    }

    // 删除车辆
    public function toDelCar(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(CarService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->toDel();
        return $this->return_result($this->returnData);
    }

    // 车牌号
    public function getPlateNumber(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(CarService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->getPlateNumber();
        return $this->return_result($this->returnData);
    }
}